summaryrefslogtreecommitdiff
path: root/src/pages/blog/micro/[page].astro
blob: 72ccdcf607e9da1f8a4d8869d8bb89f596ea4825 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
import MicroBlog from "@components/templates/MicroBlog.astro";
import Base from "@layouts/Base.astro";
import PrevNext from "@layouts/PrevNext.astro";
import { fromPosts, isMicro } from "@lib/collection/helpers";
import { identity } from "@utils/anonymous";
import type {
  GetStaticPaths,
  InferGetStaticParamsType,
  InferGetStaticPropsType,
} from "astro";

export const getStaticPaths = (async ({ paginate }) => {
  const micros = await fromPosts(isMicro, identity);

  return paginate(micros, { pageSize: 20 });
}) satisfies GetStaticPaths;

export type Params = InferGetStaticParamsType<typeof getStaticPaths>;
export type Props = InferGetStaticPropsType<typeof getStaticPaths>;

const { page } = Astro.props;

const { prev, next, first, last } = page.url;
---
<Base title="Micro Blogue">
  <main
    itemprop="mainContentOfPage"
    itemscope
    itemtype="https://schema.org/WebPageElement"
  >
    <section
      id="posts"
      itemprop="citation"
      itemscope
      itemtype="http://schema.org/Blog"
    >
      <h2 itemprop="name description">Página {page.currentPage}</h2>
      <PrevNext previous={prev} {next} {first} {last}>
        <ul>{page.data.map((micro) => <li><MicroBlog {micro} /></li>)}</ul>
      </PrevNext>
    </section>
  </main>
</Base>
<style>
  ul {
    max-width: 40ch;
    margin-inline: auto;
    margin-block: calc(var(--size-7) * 1em);
    padding-inline: 0;
    list-style-type: none;
    & > li {
      width: 100%;
      margin-block: calc(var(--size-0) * 1em);
      margin-inline: auto;
    }
  }
</style>